home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 19.zip
/
BS1 part 19
/
Lattice C disk 4.adf
/
cc_extras
/
grepdemo.c
< prev
next >
Wrap
C/C++ Source or Header
|
1988-11-07
|
636b
|
38 lines
/**
*
* This file is a simple program that demonstrates the use of the
* functions contained in the grep libraries.
*
**/
#include "stdio.h"
#include "pat.h"
char *string1 = "^[a-z]+(.*)";
char *string2 = "int";
char buf[256];
PATTERN re_gen();
main()
{
FILE *fp;
PATTERN p;
if ( (fp = fopen("grepdemo.c","r")) == NULL ) {
printf("Can't open grepdemo.c\n");
exit(1);
}
if ( (p = re_gen(string1)) == NULL ) {
printf("Can't create pattern p\n");
exit(1);
}
while ( fgets(buf,256,fp) != NULL ) {
if ( re_match(buf,p) >= 0 )
printf("%s",buf);
if ( re_smatch(string2,buf) >= 0 )
printf("%s",buf);
}
}